<?php

namespace Modules\Admin\Http\Controllers\Configurations;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Modules\Common\General\Security\Api\Gateway;
use Modules\Common\Models\AdminLog;
use Modules\Common\Models\Configurations;
use Modules\Common\Util\Api;
use Modules\Common\Util\Database;


class Update
{

    /**
     * @Route(path=/api/admin/configuration  method=put)
     */
    public function index()
    {
        Api::validate(['id' => 'required|integer']);
        $id = request('id');
        $adminUserIdDefault = auth('api')->user()->id;
        $eidDefault = auth('api')->user()->eid; 
        $sidDefault = auth('api')->user()->sid;
        Configurations::updateFromArray([
            'id' => $id,
            'name' => request('name'),
            'content' => request('content'),
            'is_enabled' => request('is_enabled'),
            'admin_user_id'=>$adminUserIdDefault,
            'eid'=>$eidDefault,
            'sid'=>$sidDefault,
        ]);
        return Api::success();
    }
}